package com.zackeus.mvvm.api.entity;

import android.os.Parcel;
import android.os.Parcelable;

import java.io.Serializable;

/**
 * 下载事件
 * @name: DownLoadStateBean
 * @author: zz
 * @date: 2022/9/6
 */
public class DownLoadStateEvent implements Serializable, Parcelable {
    /* 文件总大小 */
    final long total;

    /* 已加载文件的大小 */
    final long bytesRead;

    /* 多任务下载时的一个标记 */
    final String tag;

    public DownLoadStateEvent(long total, long bytesRead) {
        this(total, bytesRead, "");
    }

    public DownLoadStateEvent(long total, long bytesRead, String tag) {
        this.total = total;
        this.bytesRead = bytesRead;
        this.tag = tag;
    }

    public long getTotal() {
        return total;
    }

    public long getBytesRead() {
        return bytesRead;
    }

    public String getTag() {
        return tag;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.total);
        dest.writeLong(this.bytesRead);
        dest.writeString(this.tag);
    }

    protected DownLoadStateEvent(Parcel in) {
        this.total = in.readLong();
        this.bytesRead = in.readLong();
        this.tag = in.readString();
    }

    public static final Creator<DownLoadStateEvent> CREATOR = new Creator<>() {
        @Override
        public DownLoadStateEvent createFromParcel(Parcel source) {
            return new DownLoadStateEvent(source);
        }

        @Override
        public DownLoadStateEvent[] newArray(int size) {
            return new DownLoadStateEvent[size];
        }
    };
}
